package com.zhihao.takeaway.common.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LoginInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

        try{
            String token = request.getHeader("token");
//            发现用户未登录
            if(token == null){
                return false;
            }
//            response.sendRedirect(request.getContextPath()+"/login");
        }catch(Exception e){
            e.printStackTrace();
        }
        return true;
    }
}
